/*
 * @Descripttion: 护士入库（创建一条入库记录）
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-05-07 15:48:21
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-05-07 18:34:00
 */
const DB = require("../../lib/DB")
const { Success, Fail } = require("../../lib/Response")

module.exports = async function (ctx, next) {
    try {
        const medicine_lib = await DB.models.medicine_lib.create({
            storage_time: ctx.request.body.storage_time,
            medicine_name: ctx.request.body.medicine_name,
            lot_identification_mark: ctx.request.body.lot_identification_mark,
            specification: ctx.request.body.specification,
            sort_id: ctx.request.body.sort_id,
            dose: ctx.request.body.dose,
            amount: ctx.request.body.amount,
            out_amount: ctx.request.body.out_amount,
            unit_price: ctx.request.body.unit_price,
            sell_price: ctx.request.body.sell_price,
            expiration_date: ctx.request.body.expiration_date,
            expiration_flag: ctx.request.body.expiration_flag,
            manufacture_date: ctx.request.body.manufacture_date,
            manufacturer: ctx.request.body.manufacturer,
            provider: ctx.request.body.provider,
            conservator: ctx.request.body.conservator,
            memo: ctx.request.body.memo,
        })
        await next()
        ctx.body = new Success(medicine_lib.toJSON())
    } catch (e) {
        ctx.body = new Fail(e.message)
    }
}